package com.qingke.hibernate.oneday;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import com.qingke.hibernate.oneday.dao.StudentDao;
import com.qingke.hibernate.oneday.pojo.Student;

public class HibernateMappingApp {

	public static void main(String[] args) {
		SessionFactory sf = new Configuration().configure().buildSessionFactory();
		Session s = sf.openSession();
		StudentDao stuDao = new StudentDao(s);
		Student stu = stuDao.getStudentById(3);
		stuDao.delete(stu);
		System.out.println("Student: " + stu);		
		System.out.println("Student Login: " + stu.getLogin());
		System.out.println("Student Login: " + stu.getStatus());
		System.out.println("total student: " + stu.getStatus().getStudents().size());
		s.close();
		sf.close();
	}

}
